var customerColumns = [{
    id: 'com_name',
    title: '客户名称',
    type: 'string',
    columnClass: 'text-center'
},{
    id: 'com_short_name',
    title: '客户简称',
    type: 'string',
    columnClass: 'text-center'
},
    {
        id: 'com_type',
        title: '客户类型',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'industry',
        title: '行业',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'address',
        title: '地址',
        type: 'string',
        columnClass: 'text-center'
    },
    {
        id: 'telephone',
        title: '联系方式',
        type: 'string',
        width: 110,
        columnClass: 'text-center'
    },
    {
        id: 'userId',
        title: '我司负责人',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'createUser',
        title: '创建人',
        type: 'string',
        width: 75,
        columnClass: 'text-center'
    },{
        id: 'operation',
        title: '操作',
        type: 'string',
        width: 100,
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            content += '<button class="btn btn-xs btn-primary" onclick="selist(' + record.id + ');"><i class="icon-eye-open"></i>  查看联系人</button>';
            return content;
        }
    }
];
function findCusList(CertusJsonAjax,CertusFormAjax) {
    this.search = function (code, param) {
        $("#customerContainer").empty();
        $("#customerToolBarContainer").empty();
        CertusJsonAjax.dataInit("findList", {"code": code, "param": param,"userId":"0"}, customerColumns,
            "customerContainer", "customerToolBarContainer", 20, [20, 25, 30]);
    }
    var searchCode = localStorage.getItem("searchCode");
    if (searchCode==null||searchCode==undefined){
        searchCode=0;
    }
    var searchParam = localStorage.getItem("searchParam");

    if (searchCode == 0) {
        search("0","");
    } else {
        search(searchCode, searchParam);
    }
    setTimeout(function () {
        $("#searchParam").val(searchParam);
    }, 100);

    $("#searchCode").val(searchCode);

    this.changeparam = function (code) {
        var html = "";
        if (code == 0) {
            //全部
            html += '<input type="text" value="" id="searchParam" class="form-control" disabled/>';
            $("#paramt").html(html);
        } else if (code == 1) {
            //客户名称
            html += '<input type="text" value="" id="searchParam" class="form-control" placeholder="客户名称"/>';
            $("#paramt").html(html);
        } else if (code == 2 || code == 3) {
            //归属人
            html += '<input type="text" value="" id="searchParam" class="form-control" placeholder="中文名称或工号"/>';
            $("#paramt").html(html);
        }
    }
    changeparam(searchCode);

    $(".psearch").on('click', function () {
        var code = $("#searchCode").val();
        var param = $("#searchParam").val();

        localStorage.setItem("searchCode", code);
        localStorage.setItem("searchParam", param);

        search(code, param);
    });
}
//查看联系人
function selist(id) {
    window.location.href = "#/toFindCus/"+id;
}